package com.lancoo.znbkxx.teacher.adapter

import android.graphics.Color
import android.view.View
import androidx.constraintlayout.widget.Constraints
import com.chad.library.adapter.base.BaseQuickAdapter
import com.chad.library.adapter.base.BaseViewHolder
import com.lancoo.znbkxx.teacher.R
import com.lancoo.znbkxx.teacher.model.data.Four
import com.lancoo.znbkxx.teacher.model.data.Three
import com.lancoo.znbkxx.teacher.utils.DensityUtils
import kotlinx.android.synthetic.main.item_paperlibrary.view.*

/**
 * Created by wealive on 2021/3/29.
 *
 *
 */
class PaperCatlogAdapter4th (data: List<Four>) :
        BaseQuickAdapter<Four, BaseViewHolder>(data) {
    init {
        mLayoutResId = R.layout.item_paperlibrary
    }

    override fun convert(helper: BaseViewHolder, item: Four?) {
        with(helper.itemView) {
            tv_catalog.apply {
                text = item!!.FourName.let {
                    if (it.length > 5) it.substring(0, 5) + "\n" + it.substring(5,
                            it.length) else it
                }
                textSize = 9f
                setTextColor(Color.parseColor(if (item.isSelected) "#00afff" else "#333333"))
            }
            iv_arrow.visibility = View.INVISIBLE
            layoutParams = Constraints.LayoutParams(Constraints.LayoutParams.MATCH_PARENT,
                    DensityUtils.dp2px(mContext, 25f))
            setBackgroundColor(Color.parseColor(if (item!!.isSelected) "#e1f3ff" else "#00000000"))
        }
    }
}